<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../lib/test.php');
require_once ('../../simpletest/autorun.php');
require_once ('../lib/init.php');
require_once ('../data_sample/mockup_data_comment.php');

class TestFunc_processFriendComment extends UnitTestCase {
    
    function setUp(){
        global $login_button,$facebook;
        
        if(isLoggedIn()){
            try{
                $me = getOneself();
            }catch(Exception $e){
                print($login_button);
                exit();
            }
        }
    }

    /////////////////////////
    //FRIEND COMMENT CASES
    //NOTE: no need to specify the kind of posts here
    //Case5: A friend wrotes a comment on my post (regardless of where it is)
    //    5.1: A friend wrotes comments on my posts
    function test_case51(){ 
        global $commentCase51;
        $data = $commentCase51;
        $friends = array();
        
        processFriendComment($friends, $data, "FRIEND_COMMENT_ON_STATUS_FLAG");
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertTrue(count($friends) == 1);
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData("FRIEND_COMMENT_ON_STATUS_FLAG"),2);
    }
//    5.2: Two friends wrote comments on my post
    function test_case52(){ 
        global $commentCase52;
        $data = $commentCase52;
        $friends = array();
        
        processFriendComment($friends, $data, "FRIEND_COMMENT_ON_LINK_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertTrue($friend->getNumberOfData("FRIEND_COMMENT_ON_LINK_FLAG") == 1);
        $friend = $friends['100000525262538'];
        $this->assertTrue($friend->getNumberOfData("FRIEND_COMMENT_ON_LINK_FLAG") == 1);
    }
//    5.3: Two friends wrote comments on my posts, yool(3), soon(2)
    function test_case53(){ 
        global $commentCase53;
        $data = $commentCase53;
        $friends = array();
        
        processFriendComment($friends, $data, "FRIEND_COMMENT_ON_PHOTO_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertTrue($friend->getNumberOfData("FRIEND_COMMENT_ON_PHOTO_FLAG") == 3);
        $friend = $friends['100000525262538'];
        $this->assertTrue($friend->getNumberOfData("FRIEND_COMMENT_ON_PHOTO_FLAG") == 2);
    }    

}
?>
